#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
from os.path import splitext, basename, join as pjoin, walk
from distutils.core import setup
from distutils.core import Command
from unittest import TextTestRunner, TestLoader
from glob import glob

version = '0.0.1'
README = os.path.join(os.path.dirname(__file__), 'README.txt')

class TestCommand(Command):
    user_options = []

    def initialize_options(self):
        self._dir = os.getcwd()

    def finalize_options(self):
        pass

    def run(self):
        os.system('python -O pydvdtools/tests.py')

class CleanCommand(Command):
    user_options = [ ]

    def initialize_options(self):
        self._clean_me = [ ]
        for root, dirs, files in os.walk('.'):
            for f in files:
                if f.endswith('.pyo') or f.endswith('.pyc') or f.endswith('~'):
                    self._clean_me.append(pjoin(root, f))

    def finalize_options(self):
        pass

    def run(self):
        for clean_me in self._clean_me:
            try:
                os.unlink(clean_me)
            except:
                pass

setup(
    name='pydvdtools',
    version=version,
    author='Serj Poltavski',
    author_email='serge.uliss@gmail.com',
    license='GPL',
    packages=['pydvdtools', 'pydvdtools.tools'],
    cmdclass = { 'test': TestCommand, 'clean': CleanCommand }
    )
